package com.fr.report.core.cal;

import com.fr.base.ArrayUtils;
import com.fr.base.ColumnRow;
import com.fr.base.FCloneable;
import com.fr.base.FRContext;
import com.fr.base.Inter;
import com.fr.base.core.FT;
import com.fr.base.core.list.FRCacheList;
import com.fr.base.core.list.IntList;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.data.TableData;
import com.fr.data.impl.DBTableData;
import com.fr.data.impl.GroupCachedAdapter;
import com.fr.data.impl.TableDataAdapter;
import com.fr.data.impl.UnCacheAdapter;
import com.fr.report.AbstractReport;
import com.fr.report.CellElement;
import com.fr.report.FloatElement;
import com.fr.report.Margin;
import com.fr.report.PageInfo;
import com.fr.report.PageSet;
import com.fr.report.PaperSetting;
import com.fr.report.PaperSize;
import com.fr.report.Report;
import com.fr.report.ReportPage;
import com.fr.report.ReportSettings;
import com.fr.report.TemplateReport;
import com.fr.report.WorkSheet;
import com.fr.report.cellElement.CellExpandAttr;
import com.fr.report.cellElement.CellPageAttr;
import com.fr.report.cellElement.Formula;
import com.fr.report.cellElement.TableDataColumn;
import com.fr.report.cellElement.core.DSColumn;
import com.fr.report.cellElement.core.FunctionGrouper;
import com.fr.report.cellElement.core.Group;
import com.fr.report.core.ActiveReport;
import com.fr.report.core.DynamicValueList;
import com.fr.report.core.ReportHelper;
import com.fr.report.core.ReportUtils;
import com.fr.report.core.ScriptUtils;
import com.fr.report.core.SheetUtils;
import com.fr.report.highlight.Highlight;
import com.fr.report.highlight.HighlightGroup;
import com.fr.report.js.JavaScript;
import com.fr.report.js.NameJavaScript;
import com.fr.report.js.NameJavaScriptGroup;
import com.fr.report.parameter.Parameter;
import com.fr.report.script.AbstractNameSpace;
import com.fr.report.script.Calculator;
import com.fr.report.script.Function;
import com.fr.report.script.NameSpace;
import com.fr.report.script.Primitive;
import com.fr.report.script.core.FArray;
import com.fr.report.script.core.parser.ColumnRowLiteral;
import com.fr.report.script.core.parser.ColumnRowRange;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

public class LayerReport extends ActiveReport
{
  private Map parameterMap;
  private ReportSettings reportSettings;
  private boolean executing = false;
  private TemplateReport report4page;
  private List page_row_index_ft_list = new ArrayList();
  private List page_column_index_ft_list = new ArrayList();
  private int paperPaintHeight;
  private LayerThread thread;
  private final Object lock = new Object();
  private boolean isWaiting = false;
  private int largest_index_in_page_row_list = 0;
  private final Object lock4ReportPage = new Object();
  private boolean waiting4Pages = false;
  private static final int WARNING_LINE = 200;
  private static final int SATISFY_LINE = 100;

  private void wakeup()
  {
  }

  private void sleepdown()
  {
  }

  public LayerReport(TemplateReport paramTemplateReport, Map paramMap)
  {
    super(paramTemplateReport);
    this.parameterMap = paramMap;
    this.reportSettings = ReportUtils.getReportSettings(paramTemplateReport);
    PaperSize localPaperSize = this.reportSettings.getPaperSize();
    Margin localMargin = this.reportSettings.getMargin();
    double d1 = localPaperSize.getWidth();
    double d2 = localPaperSize.getHeight();
    if (this.reportSettings.getOrientation() == 1)
    {
      d1 = localPaperSize.getHeight();
      d2 = localPaperSize.getWidth();
    }
    int i = (int)((d1 - localMargin.getLeft() - localMargin.getRight()) * this.reportSettings.getResolution());
    this.paperPaintHeight = (int)((d2 - localMargin.getTop() - localMargin.getBottom() - this.reportSettings.getHeaderHeight() - this.reportSettings.getFooterHeight()) * this.reportSettings.getResolution());
    DynamicValueList localDynamicValueList = ReportHelper.getColumnWidthList(paramTemplateReport);
    int j = 0;
    FT localFT = new FT(0, 1);
    this.page_column_index_ft_list.add(localFT);
    int k = 0;
    int l = paramTemplateReport.getColumnCount();
    while (k < l)
    {
      j += localDynamicValueList.get(k);
      if (j > i)
      {
        localFT = new FT(k, k + 1);
        this.page_column_index_ft_list.add(localFT);
        j = localDynamicValueList.get(k);
      }
      else
      {
        localFT.setTo(k + 1);
      }
      ++k;
    }
  }

  public void addCellElement(CellElement paramCellElement)
  {
    throw new UnsupportedOperationException();
  }

  public void addCellElement(CellElement paramCellElement, boolean paramBoolean)
  {
    throw new UnsupportedOperationException();
  }

  public void addFloatElement(FloatElement paramFloatElement)
  {
    throw new UnsupportedOperationException();
  }

  public void bringFloatElementForward(FloatElement paramFloatElement)
  {
    throw new UnsupportedOperationException();
  }

  public void bringFloatElementToFront(FloatElement paramFloatElement)
  {
    throw new UnsupportedOperationException();
  }

  public Iterator cellIterator()
  {
    return init_report4page().cellIterator();
  }

  public Iterator floatIterator()
  {
    return init_report4page().floatIterator();
  }

  public PageSet generateReportPageSet(PaperSetting paramPaperSetting)
  {
    return new LayerSet(this);
  }

  public CellElement getCellElement(int paramInt1, int paramInt2)
  {
    return init_report4page().getCellElement(paramInt1, paramInt2);
  }

  public Object getCellValue(int paramInt1, int paramInt2)
  {
    return init_report4page().getCellValue(paramInt1, paramInt2);
  }

  public Iterator getColumn(int paramInt)
  {
    return init_report4page().getColumn(paramInt);
  }

  public int getColumnCount()
  {
    return init_report4page().getColumnCount();
  }

  public FloatElement getFloatElement(String paramString)
  {
    return init_report4page().getFloatElement(paramString);
  }

  public Iterator getRow(int paramInt)
  {
    return init_report4page().getRow(paramInt);
  }

  public int getRowCount()
  {
    return init_report4page().getRowCount();
  }

  public void insertColumn(int paramInt)
  {
    throw new UnsupportedOperationException();
  }

  public void insertRow(int paramInt)
  {
    throw new UnsupportedOperationException();
  }

  public Iterator intersect(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    return init_report4page().intersect(paramInt1, paramInt2, paramInt3, paramInt4);
  }

  public void merge(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    throw new UnsupportedOperationException();
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    throw new UnsupportedOperationException();
  }

  public void removeAllCellElements()
  {
    throw new UnsupportedOperationException();
  }

  public void removeAllFloatElements()
  {
    throw new UnsupportedOperationException();
  }

  public boolean removeCellElement(CellElement paramCellElement)
  {
    throw new UnsupportedOperationException();
  }

  public CellElement removeCellElement(int paramInt1, int paramInt2)
  {
    throw new UnsupportedOperationException();
  }

  public void removeColumn(int paramInt)
  {
    throw new UnsupportedOperationException();
  }

  public FloatElement removeFloatElement(String paramString)
  {
    throw new UnsupportedOperationException();
  }

  public boolean removeFloatElement(FloatElement paramFloatElement)
  {
    throw new UnsupportedOperationException();
  }

  public void removeRow(int paramInt)
  {
    throw new UnsupportedOperationException();
  }

  public void sendFloatElementBackward(FloatElement paramFloatElement)
  {
    throw new UnsupportedOperationException();
  }

  public void sendFloatElementToBack(FloatElement paramFloatElement)
  {
    throw new UnsupportedOperationException();
  }

  public void recalculate(Map paramMap)
  {
    throw new UnsupportedOperationException();
  }

  public void setCellValue(int paramInt1, int paramInt2, Object paramObject)
  {
    throw new UnsupportedOperationException();
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    throw new UnsupportedOperationException();
  }

  private Report init_report4page()
  {
    if (this.report4page == null)
    {
      try
      {
        this.report4page = ((TemplateReport)this.packee.clone());
      }
      catch (CloneNotSupportedException localCloneNotSupportedException)
      {
        FRContext.getLogger().log(Level.WARNING, localCloneNotSupportedException.getMessage(), localCloneNotSupportedException);
        this.report4page = new WorkSheet();
      }
      this.report4page.reset();
      for (int i = 0; i < this.packee.getColumnCount(); ++i)
        this.report4page.setColumnWidth(i, this.packee.getColumnWidth(i));
      this.executing = true;
      this.thread = new LayerThread(this, null);
      this.thread.start();
    }
    return this.report4page;
  }

  public Thread getLayerThread()
  {
    return this.thread;
  }

  public void release()
  {
    if (this.report4page != null)
      ((AbstractReport)this.report4page).releaseCellElementCache();
  }

  protected void finalize()
    throws Throwable
  {
    finalize();
    release();
  }

  static TemplateReport access$100(LayerReport paramLayerReport)
  {
    return paramLayerReport.packee;
  }

  static Map access$200(LayerReport paramLayerReport)
  {
    return paramLayerReport.parameterMap;
  }

  static boolean access$400(LayerReport paramLayerReport)
  {
    return paramLayerReport.executing;
  }

  static Object access$500(LayerReport paramLayerReport)
  {
    return paramLayerReport.lock;
  }

  static void access$600(LayerReport paramLayerReport)
  {
    paramLayerReport.wakeup();
  }

  static TemplateReport access$700(LayerReport paramLayerReport)
  {
    return paramLayerReport.packee;
  }

  static boolean access$402(LayerReport paramLayerReport, boolean paramBoolean)
  {
    return (paramLayerReport.executing = paramBoolean);
  }

  static Object access$900(LayerReport paramLayerReport)
  {
    return paramLayerReport.lock4ReportPage;
  }

  static boolean access$1000(LayerReport paramLayerReport)
  {
    return paramLayerReport.waiting4Pages;
  }

  static boolean access$1002(LayerReport paramLayerReport, boolean paramBoolean)
  {
    return (paramLayerReport.waiting4Pages = paramBoolean);
  }

  static Report access$1100(LayerReport paramLayerReport)
  {
    return paramLayerReport.init_report4page();
  }

  static List access$1200(LayerReport paramLayerReport)
  {
    return paramLayerReport.page_row_index_ft_list;
  }

  static List access$1300(LayerReport paramLayerReport)
  {
    return paramLayerReport.page_column_index_ft_list;
  }

  static TemplateReport access$1400(LayerReport paramLayerReport)
  {
    return paramLayerReport.report4page;
  }

  static int access$1502(LayerReport paramLayerReport, int paramInt)
  {
    return (paramLayerReport.largest_index_in_page_row_list = paramInt);
  }

  static int access$1500(LayerReport paramLayerReport)
  {
    return paramLayerReport.largest_index_in_page_row_list;
  }

  static boolean access$1600(LayerReport paramLayerReport)
  {
    return paramLayerReport.isWaiting;
  }

  static LayerThread access$1700(LayerReport paramLayerReport)
  {
    return paramLayerReport.thread;
  }

  static TemplateReport access$1900(LayerReport paramLayerReport)
  {
    return paramLayerReport.packee;
  }

  static TemplateReport access$2000(LayerReport paramLayerReport)
  {
    return paramLayerReport.packee;
  }

  static void access$2200(LayerReport paramLayerReport)
  {
    paramLayerReport.sleepdown();
  }

  static int access$2400(LayerReport paramLayerReport)
  {
    return paramLayerReport.paperPaintHeight;
  }

  private static class LayerValueNameSpace
    implements NameSpace
  {
    private Object currentValue;
    private List psinfo_list;

    private LayerValueNameSpace(Object paramObject, List paramList)
    {
      this.currentValue = paramObject;
      this.psinfo_list = paramList;
    }

    private void set(Object paramObject, List paramList)
    {
      this.currentValue = paramObject;
      this.psinfo_list = paramList;
    }

    public Object getCellElementAttribute(ColumnRow paramColumnRow, Object paramObject, Calculator paramCalculator)
    {
      return null;
    }

    public Function getMethod(Object paramObject, Calculator paramCalculator)
    {
      return null;
    }

    public Object getVariable(Object paramObject, Calculator paramCalculator)
    {
      int i;
      if ("$$$".equals(paramObject))
        return this.currentValue;
      if ((paramObject instanceof ColumnRowRange) && (((ColumnRowRange)paramObject).getTo() == null))
      {
        ColumnRowLiteral localColumnRowLiteral = ((ColumnRowRange)paramObject).getFrom();
        paramObject = (localColumnRowLiteral == null) ? null : localColumnRowLiteral.getTargetColumnRow();
      }
      if ((paramObject instanceof ColumnRow) && (this.psinfo_list != null))
        for (i = 0; i < this.psinfo_list.size(); ++i)
        {
          LayerReport.PSInfo localPSInfo = (LayerReport.PSInfo)this.psinfo_list.get(i);
          if ((((ColumnRow)paramObject).getRow() == LayerReport.PSInfo.access$2800(localPSInfo).current.getRow()) && (((ColumnRow)paramObject).getColumn() == LayerReport.PSInfo.access$2800(localPSInfo).current.getColumn()))
            return LayerReport.PSInfo.access$2900(localPSInfo).getValue();
        }
      return null;
    }

    LayerValueNameSpace(Object paramObject, List paramList, LayerReport.1 param1)
    {
      this(paramObject, paramList);
    }

    static void access$2700(LayerValueNameSpace paramLayerValueNameSpace, Object paramObject, List paramList)
    {
      paramLayerValueNameSpace.set(paramObject, paramList);
    }
  }

  private static class PSInfo
  {
    private LayerSheetExecuter.LayerFamilyMember lfm;
    private CellElement cell;

    private PSInfo(LayerSheetExecuter.LayerFamilyMember paramLayerFamilyMember, CellElement paramCellElement)
    {
      this.lfm = paramLayerFamilyMember;
      this.cell = paramCellElement;
    }

    PSInfo(LayerSheetExecuter.LayerFamilyMember paramLayerFamilyMember, CellElement paramCellElement, LayerReport.1 param1)
    {
      this(paramLayerFamilyMember, paramCellElement);
    }

    static LayerSheetExecuter.LayerFamilyMember access$2800(PSInfo paramPSInfo)
    {
      return paramPSInfo.lfm;
    }

    static CellElement access$2900(PSInfo paramPSInfo)
    {
      return paramPSInfo.cell;
    }
  }

  private static class Delegate
  {
    private Object object;

    public Delegate(Object paramObject)
    {
      setObject(paramObject);
    }

    public void setObject(Object paramObject)
    {
      this.object = paramObject;
    }

    public Object getObject()
    {
      return this.object;
    }
  }

  public class LayerSE extends LayerSheetExecuter
  {
    private Report _report4page;
    private LayerReport.LayerNameSpace lns;
    private int current_page_height;
    private FT current_page_head_rows;
    private FT next_page_head_rows;
    private LayerReport.LayerValueNameSpace lvns;
    private final LayerReport this$0;

    private LayerSE(, TemplateReport paramTemplateReport, Map paramMap)
    {
      super(paramTemplateReport, paramMap);
      this.this$0 = paramLayerReport;
      this.current_page_height = 0;
      this.current_page_head_rows = null;
      this.next_page_head_rows = null;
      this.lvns = new LayerReport.LayerValueNameSpace(null, null, null);
      this._report4page = LayerReport.access$1400(paramLayerReport);
      ((AbstractReport)this._report4page).cacheCellElement(4096, 2, true);
      this.lns = new LayerReport.LayerNameSpace(paramLayerReport, null);
      this.calculator.pushNameSpace(this.lns);
    }

    private void appendOnePage()
    {
      int i;
      if (this.current_page_head_rows != null)
        LayerReport.access$1200(this.this$0).add(new FT[] { this.current_page_head_rows, paramFT });
      else
        LayerReport.access$1200(this.this$0).add(new FT[] { paramFT });
      if (this.next_page_head_rows != null)
        this.current_page_head_rows = new FT(this.next_page_head_rows.getFrom(), this.next_page_head_rows.getTo());
      this.current_page_height = 0;
      if (this.current_page_head_rows != null)
        for (i = this.current_page_head_rows.getFrom(); i < this.current_page_head_rows.getTo(); ++i)
          this.current_page_height += this._report4page.getRowHeight(i);
      if ((!(LayerReport.LayerThread.access$2100(LayerReport.access$1700(this.this$0)))) && (LayerReport.access$1200(this.this$0).size() - LayerReport.access$1500(this.this$0) > 100))
      {
        synchronized (LayerReport.access$900(this.this$0))
        {
          if (LayerReport.access$1000(this.this$0))
          {
            FRContext.getLogger().info(Inter.getLocText("Layer-Generated_Pages") + ":" + LayerReport.access$1200(this.this$0).size());
            FRContext.getLogger().info(Inter.getLocText("Layer-Wake_Up_Thread_For_Page_Retriever"));
            LayerReport.access$900(this.this$0).notifyAll();
            LayerReport.access$1002(this.this$0, false);
          }
        }
        LayerReport.access$2200(this.this$0);
      }
    }

    public void dynamic_ex()
    {
      SheetUtils.calculateDefaultParent(this.report);
      buildGenealogy();
      FT localFT = new FT(0, 0);
      do_fill(localFT);
      if (localFT.to > localFT.from)
        appendOnePage(localFT);
    }

    private void do_fill()
    {
      ArrayList localArrayList = new ArrayList();
      dealwith_layer(localArrayList);
      ex_FamilyMemberArray((LayerSheetExecuter.LayerFamilyMember[])localArrayList.toArray(new LayerSheetExecuter.LayerFamilyMember[localArrayList.size()]), this.data, null, 0, paramFT, null);
    }

    private int ex_FamilyMemberArray(, TableData paramTableData, int[] paramArrayOfInt, int paramInt, FT paramFT, List paramList)
    {
      sort_FamilyMemberArray(paramArrayOfLayerFamilyMember);
      int i = 0;
      int j = 0;
      do
      {
        if (j >= paramArrayOfLayerFamilyMember.length)
          break;
        ArrayList localArrayList = new ArrayList();
        LayerSheetExecuter.LayerFamilyMember localLayerFamilyMember1 = paramArrayOfLayerFamilyMember[j];
        int k = localLayerFamilyMember1.rect.bottom;
        for (LayerSheetExecuter.LayerFamilyMember localLayerFamilyMember2 = localLayerFamilyMember1; localLayerFamilyMember2.rect.top <= k; localLayerFamilyMember2 = paramArrayOfLayerFamilyMember[j])
        {
          k = Math.max(k, localLayerFamilyMember2.rect.bottom);
          localArrayList.add(localLayerFamilyMember2);
          if (++j >= paramArrayOfLayerFamilyMember.length)
            break;
        }
        i += ex_concurrent((LayerSheetExecuter.LayerFamilyMember[])localArrayList.toArray(new LayerSheetExecuter.LayerFamilyMember[localArrayList.size()]), paramTableData, k - localLayerFamilyMember1.rect.top + 1, paramArrayOfInt, paramInt + i, paramFT, paramList);
      }
      while (!(LayerReport.LayerThread.access$2100(LayerReport.access$1700(this.this$0))));
      return i;
    }

    public boolean needDataGroupCache()
    {
      return ((this.dsColumn != null) && (((!(this.dsColumn.getGrouper() instanceof FunctionGrouper)) || (((FunctionGrouper)this.dsColumn.getGrouper()).getDivideMode() != 1))));
    }

    public String getKeyColumnName()
    {
      if (needDataGroupCache())
        return TableDataColumn.getColumnName(this.dsColumn.getColumn());
      return null;
    }

    private Iterator generateGroupIterator(, TableData paramTableData, int[] paramArrayOfInt)
    {
      int i = paramLayerFamilyMember.getColumnIndex(paramTableData);
      if (i < -1)
      {
        Object localObject2;
        Object localObject1 = paramLayerFamilyMember.current.getValue();
        if (localObject1 instanceof Formula)
        {
          localObject2 = ((Formula)localObject1).getContent();
          try
          {
            localObject1 = this.calculator.eval(((String)localObject2).substring(1));
          }
          catch (Exception localException)
          {
            FRContext.getLogger().log(Level.WARNING, localException.getMessage(), localException);
          }
        }
        LayerReport.LayerNameSpace.access$2300(this.lns, paramLayerFamilyMember.current.getColumn(), paramLayerFamilyMember.current.getRow(), new LayerReport.Delegate(localObject1));
        if ((localObject1 instanceof FArray) && (paramLayerFamilyMember.current.getCellExpandAttr() != null) && (paramLayerFamilyMember.current.getCellExpandAttr().getDirection() == 0))
        {
          localObject2 = new Group[((FArray)localObject1).length()];
          int j = 0;
          int k = ((FArray)localObject1).length();
          while (j < k)
          {
            localObject2[j] = new Group(((FArray)localObject1).elementAt(j), new int[0]);
            ++j;
          }
          return Arrays.asList(localObject2).iterator();
        }
        return Arrays.asList(new Group[] { new Group(localObject1, new int[0]) }).iterator();
      }
      return ((Iterator)((DSColumn)paramLayerFamilyMember.current.getValue()).dataIterator(paramTableData, i, paramArrayOfInt, this.calculator));
    }

    private int ex_concurrent(, TableData paramTableData, int paramInt1, int[] paramArrayOfInt, int paramInt2, FT paramFT, List paramList)
    {
      int i = 0;
      Iterator[] arrayOfIterator = new Iterator[paramArrayOfLayerFamilyMember.length];
      for (int j = 0; j < paramArrayOfLayerFamilyMember.length; ++j)
        arrayOfIterator[j] = generateGroupIterator(paramArrayOfLayerFamilyMember[j], paramTableData, paramArrayOfInt);
      j = -1;
      int k = 0;
      if (paramList == null)
        paramList = new ArrayList();
      int l = paramList.size();
      int[] arrayOfInt1 = new int[0];
      while (((arrayOfInt1 = __iterator_array_has_next(arrayOfIterator)).length > 0) && (!(LayerReport.LayerThread.access$2100(LayerReport.access$1700(this.this$0)))))
      {
        k = 0;
        ++j;
        for (int i1 = 0; i1 < arrayOfInt1.length; ++i1)
        {
          int i2 = 0;
          int i3 = arrayOfInt1[i1];
          Group localGroup = (Group)arrayOfIterator[i3].next();
          LayerSheetExecuter.LayerFamilyMember localLayerFamilyMember = paramArrayOfLayerFamilyMember[i3];
          CellElement localCellElement = localLayerFamilyMember.current;
          try
          {
            int i9;
            int i10;
            int i11;
            int i12;
            int i4 = (j > 0) ? localCellElement.getRow() + paramInt2 + paramInt1 : localCellElement.getRow() + paramInt2;
            int i6 = this._report4page.getRowCount();
            int i7 = i4 + localCellElement.getRowSpan() - i6;
            int[] arrayOfInt2 = null;
            if (i7 > 0)
            {
              arrayOfInt2 = new int[i7];
              localObject = ReportHelper.getRowHeightList(this._report4page);
              i8 = localCellElement.getRow() + localCellElement.getRowSpan() - i7;
              for (i9 = 0; i9 < i7; ++i9)
              {
                i10 = i8 + i9;
                i11 = i6 + i9;
                i12 = this.report.getRowHeight(i10);
                ((DynamicValueList)localObject).insert(i11);
                ((DynamicValueList)localObject).set(i11, i12);
                arrayOfInt2[i9] = i11;
                if (this.repeat_page_head_rows != null)
                  if (this.repeat_page_head_rows.getFrom() == i10)
                    if ((this.next_page_head_rows == null) || (this.next_page_head_rows.getTo() < i11))
                      this.next_page_head_rows = new FT(i11, i11 + 1);
                    else
                      this.next_page_head_rows.setTo(i11 + 1);
                  else if ((this.repeat_page_head_rows.getFrom() < i10) && (this.repeat_page_head_rows.getTo() > i10))
                    this.next_page_head_rows.setTo(i11 + 1);
              }
            }
            localCellElement = localLayerFamilyMember.current.clone(localCellElement.getColumn(), i4, localCellElement.getColumnSpan(), localCellElement.getRowSpan());
            Object localObject = localGroup.getValue();
            localCellElement.setValue(localObject);
            LayerReport.LayerNameSpace.access$2300(this.lns, localLayerFamilyMember.current.getColumn(), localLayerFamilyMember.current.getRow(), localObject);
            dealwith_highlight(localCellElement, this._report4page);
            dealWithHyperLink(localCellElement, paramList);
            int i8 = -1;
            CellPageAttr localCellPageAttr = localCellElement.getCellPageAttr();
            if (localCellPageAttr != null)
              if (localCellPageAttr.isPageBeforeRow())
                i8 = localCellElement.getRow();
              else if (localCellPageAttr.isPageAfterRow())
                i8 = localCellElement.getRow() + localCellElement.getRowSpan();
            if ((i8 > paramFT.from) && (((arrayOfInt2 == null) || (arrayOfInt2[0] > i8))))
            {
              appendOnePage(new FT(paramFT.from, i8));
              paramFT.setFrom(i8);
              paramFT.setTo(i8);
            }
            if (arrayOfInt2 != null)
              for (i10 = 0; i10 < arrayOfInt2.length; ++i10)
              {
                i11 = arrayOfInt2[i10];
                i12 = this._report4page.getRowHeight(i11);
                this.current_page_height += i12;
                if (((i8 == i11) && (i8 > paramFT.from)) || (this.current_page_height > LayerReport.access$2400(this.this$0)))
                {
                  appendOnePage(new FT(paramFT.from, paramFT.to));
                  paramFT.setFrom(i11);
                  paramFT.setTo(i11 + 1);
                  this.current_page_height += i12;
                }
                else
                {
                  paramFT.setTo(i11 + 1);
                }
              }
            if ((i8 > paramFT.from) && (arrayOfInt2 != null) && (arrayOfInt2[(arrayOfInt2.length - 1)] + 1 == i8))
            {
              appendOnePage(new FT(paramFT.from, i8));
              paramFT.setFrom(i8);
              paramFT.setTo(i8);
            }
          }
          catch (CloneNotSupportedException localCloneNotSupportedException)
          {
            FRContext.getLogger().log(Level.WARNING, localCloneNotSupportedException.getMessage(), localCloneNotSupportedException);
          }
          this._report4page.addCellElement(localCellElement);
          if (j > 0)
            i2 = paramInt1;
          if (localLayerFamilyMember.sons != null)
          {
            if (paramList.size() > l)
              for (i5 = paramList.size() - 1; i5 >= l; --i5)
                paramList.remove(i5);
            paramList.add(new LayerReport.PSInfo(localLayerFamilyMember, localCellElement, null));
            int i5 = ex_FamilyMemberArray((LayerSheetExecuter.LayerFamilyMember[])localLayerFamilyMember.sons.toArray(new LayerSheetExecuter.LayerFamilyMember[localLayerFamilyMember.sons.size()]), paramTableData, localGroup.getArray(), paramInt2 + i2, paramFT, paramList);
            i2 += i5;
            if (i5 > 0)
            {
              localCellElement.setRowSpan(localCellElement.getRowSpan() + i5);
              this._report4page.addCellElement(localCellElement, true);
            }
          }
          k = Math.max(k, i2);
          if (LayerReport.LayerThread.access$2100(LayerReport.access$1700(this.this$0)))
            break;
        }
        paramInt2 += k;
        i += k;
      }
      return i;
    }

    private int[] __iterator_array_has_next()
    {
      IntList localIntList = new IntList();
      for (int i = 0; i < paramArrayOfIterator.length; ++i)
        if (paramArrayOfIterator[i].hasNext())
          localIntList.add(i);
      return localIntList.toArray();
    }

    public TableDataAdapter createDBTableDataAdapter(, String paramString)
    {
      Object localObject;
      if (paramDBTableData == null)
        return null;
      if (needDataGroupCache())
        localObject = new GroupCachedAdapter(paramDBTableData.getDatabase(), paramString, getKeyColumnName());
      else
        localObject = new UnCacheAdapter(paramDBTableData.getDatabase(), paramString);
      return ((TableDataAdapter)localObject);
    }

    private void dealWithHyperLink(, List paramList)
    {
      if (paramCellElement == null)
        return;
      if (paramCellElement.getNameHyperlinkGroup() != null)
      {
        ColumnRow localColumnRow = ColumnRow.valueOf(paramCellElement.getColumn(), paramCellElement.getRow());
        this.calculator.setCurrentColumnRow(localColumnRow);
        this.calculator.pushNameSpace(this.lvns);
        this.calculator.removeNameSpace(this.lns);
        NameJavaScriptGroup localNameJavaScriptGroup = paramCellElement.getNameHyperlinkGroup();
        for (int i = 0; i < localNameJavaScriptGroup.size(); ++i)
        {
          int j;
          JavaScript localJavaScript = localNameJavaScriptGroup.getNameHyperlink(i).getJavaScript();
          Parameter[] arrayOfParameter = localJavaScript.getParameters();
          if (!(ArrayUtils.isEmpty(arrayOfParameter)))
            for (j = 0; j < arrayOfParameter.length; ++j)
            {
              Parameter localParameter = arrayOfParameter[j];
              Object localObject = localParameter.getValue();
              if (localObject instanceof Formula)
              {
                LayerReport.LayerValueNameSpace.access$2700(this.lvns, paramCellElement.getValue(), paramList);
                Formula localFormula = (Formula)localObject;
                localFormula.setResult(ScriptUtils.executeFormula(this.calculator, localFormula, localColumnRow));
              }
            }
        }
        this.calculator.removeNameSpace(this.lvns);
        this.calculator.pushNameSpace(this.lns);
      }
    }

    private void dealwith_highlight(, Report paramReport)
    {
      if ((paramCellElement == null) || (paramReport == null))
        return;
      HighlightGroup localHighlightGroup = paramCellElement.getHighlightGroup();
      if (localHighlightGroup != null)
      {
        Report localReport = this.calculator.getCurrentReport();
        this.calculator.setCurrentReport(paramReport);
        this.calculator.setCurrentColumnRow(ColumnRow.valueOf(paramCellElement.getColumn(), paramCellElement.getRow()));
        this.calculator.pushNameSpace(this.lvns);
        this.calculator.removeNameSpace(this.lns);
        for (int i = 0; i < localHighlightGroup.size(); ++i)
        {
          Highlight localHighlight = localHighlightGroup.getHighlight(i);
          if (localHighlight.eval(paramCellElement, this.calculator))
            localHighlight.action(paramCellElement, this.calculator);
        }
        paramCellElement.setHighlightGroup(null);
        this.calculator.setCurrentReport(localReport);
        this.calculator.removeNameSpace(this.lvns);
        this.calculator.pushNameSpace(this.lns);
      }
    }

    LayerSE(, TemplateReport paramTemplateReport, Map paramMap, LayerReport.1 param1)
    {
      this(paramLayerReport, paramTemplateReport, paramMap);
    }

    static LayerReport.LayerNameSpace access$800(LayerSE paramLayerSE)
    {
      return paramLayerSE.lns;
    }
  }

  private class LayerNameSpace extends AbstractNameSpace
  {
    private NameSpace parent;
    private Object[][] value2D;
    private final LayerReport this$0;

    LayerNameSpace(, NameSpace paramNameSpace)
    {
      this.this$0 = paramLayerReport;
      this.parent = paramNameSpace;
      this.value2D = new Object[LayerReport.access$1900(paramLayerReport).getRowCount()][];
    }

    private void refreshColumnRowEl(, int paramInt2, Object paramObject)
    {
      if (this.value2D.length > paramInt2)
      {
        Object[] arrayOfObject = this.value2D[paramInt2];
        if (arrayOfObject == null)
        {
          arrayOfObject = new Object[LayerReport.access$2000(this.this$0).getColumnCount()];
          this.value2D[paramInt2] = arrayOfObject;
        }
        if (arrayOfObject[paramInt1] != null)
        {
          Object localObject = arrayOfObject[paramInt1];
          if (localObject instanceof LayerReport.Delegate)
            return;
          if (localObject instanceof List)
          {
            ((List)localObject).add(paramObject);
          }
          else
          {
            FRCacheList localFRCacheList = new FRCacheList(2048, "V2D");
            localFRCacheList.add(localObject);
            localFRCacheList.add(paramObject);
            arrayOfObject[paramInt1] = localFRCacheList;
          }
        }
        else
        {
          arrayOfObject[paramInt1] = paramObject;
        }
      }
    }

    public Function getMethod(, Calculator paramCalculator)
    {
      Function localFunction = (this.parent == null) ? null : this.parent.getMethod(paramObject, paramCalculator);
      return ((localFunction == null) ? super.getMethod(paramObject, paramCalculator) : localFunction);
    }

    public Object getCellElementAttribute(, Object paramObject, Calculator paramCalculator)
    {
      return null;
    }

    public Object getVariable(, Calculator paramCalculator)
    {
      Object localObject = null;
      if (this.parent != null)
        localObject = this.parent.getVariable(paramObject, paramCalculator);
      if (localObject != null)
        return localObject;
      return super.getVariable(paramObject, paramCalculator);
    }

    protected Object resolveColumnRowIntersect(, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
    {
      ArrayList localArrayList = new ArrayList();
      for (int i = 0; i < paramInt4; ++i)
      {
        int j = paramInt2 + i;
        if (this.value2D.length <= j)
          break label179:
        Object[] arrayOfObject = this.value2D[j];
        if (arrayOfObject == null)
          break label179:
        for (int k = 0; k < paramInt3; ++k)
        {
          int l = paramInt1 + k;
          if (arrayOfObject.length <= l)
            break label173:
          Object localObject2 = arrayOfObject[l];
          if (localObject2 instanceof LayerReport.Delegate)
            localObject2 = ((LayerReport.Delegate)localObject2).getObject();
          if (localObject2 instanceof FArray)
            localArrayList.addAll(((FArray)localObject2).toList());
          else if (localObject2 instanceof List)
            localArrayList.addAll((List)localObject2);
          else if (localObject2 != null)
            localArrayList.add(localObject2);
        }
      }
      label173: label179: Object localObject1 = null;
      if (localArrayList.size() == 0)
        localObject1 = Primitive.NULL;
      else if (localArrayList.size() == 1)
        localObject1 = localArrayList.get(0);
      else
        localObject1 = new FArray(localArrayList);
      return ((localObject1 == null) ? Primitive.NULL : localObject1);
    }

    public void release()
    {
      for (int i = 0; i < this.value2D.length; ++i)
      {
        if (this.value2D[i] == null)
          break label67:
        for (int j = 0; j < this.value2D[i].length; ++j)
        {
          Object localObject = this.value2D[i][j];
          if (localObject instanceof List)
            ((List)localObject).clear();
        }
      }
      label67:
    }

    static void access$2300(LayerNameSpace paramLayerNameSpace, int paramInt2, Object paramObject)
    {
      paramLayerNameSpace.refreshColumnRowEl(paramInt1, paramInt2, paramObject);
    }
  }

  private class LayerSet extends PageSet
  {
    private int current_index_in_page_row_list;
    private int current_index_in_page_column_list;
    private PageInfo pageInfo;
    private boolean released;
    private final LayerReport this$0;

    LayerSet()
    {
      this.this$0 = paramLayerReport;
      this.current_index_in_page_row_list = -1;
      this.current_index_in_page_column_list = -1;
      this.pageInfo = new PageInfo();
      this.released = false;
      LayerReport.access$1100(paramLayerReport);
    }

    public int size()
    {
      return ((LayerReport.access$400(this.this$0)) ? 2147483647 : LayerReport.access$1200(this.this$0).size() * LayerReport.access$1300(this.this$0).size());
    }

    public boolean sizePredictable()
    {
      return (!(LayerReport.access$400(this.this$0)));
    }

    public ReportPage getPage()
    {
      if (paramInt < 0)
        return null;
      if (hasPage(paramInt))
      {
        ReportPage localReportPage = new ReportPage(LayerReport.access$1400(this.this$0), new PageInfo(this.pageInfo.getTotalPages()), null, (FT[])LayerReport.access$1200(this.this$0).get(this.current_index_in_page_row_list), new FT[] { (FT)LayerReport.access$1300(this.this$0).get(this.current_index_in_page_column_list) }, this.current_index_in_page_column_list + 1, this.current_index_in_page_row_list + 1);
        this.pageInfo.setTotalPages(paramInt + 1);
        return localReportPage;
      }
      return null;
    }

    private boolean hasPage()
    {
      this.current_index_in_page_row_list = (paramInt / LayerReport.access$1300(this.this$0).size());
      LayerReport.access$1502(this.this$0, Math.max(LayerReport.access$1500(this.this$0), this.current_index_in_page_row_list));
      int i = LayerReport.access$1200(this.this$0).size() - this.current_index_in_page_row_list;
      if ((i <= 0) && (!(LayerReport.access$1600(this.this$0))))
      {
        if (LayerReport.access$400(this.this$0))
        {
          try
          {
            synchronized (LayerReport.access$900(this.this$0))
            {
              FRContext.getLogger().info(Inter.getLocText("Layer-Waiting_For_Page_Number") + ":" + paramInt);
              LayerReport.access$1002(this.this$0, true);
              LayerReport.access$900(this.this$0).wait();
            }
          }
          catch (InterruptedException localInterruptedException)
          {
            FRContext.getLogger().log(Level.WARNING, localInterruptedException.getMessage(), localInterruptedException);
          }
          return hasPage(paramInt);
        }
        return false;
      }
      if ((i < 200) && (LayerReport.access$1600(this.this$0)))
        LayerReport.access$600(this.this$0);
      this.current_index_in_page_column_list = (paramInt % LayerReport.access$1300(this.this$0).size());
      return true;
    }

    public void release()
    {
      if (!(this.released))
      {
        LayerReport.access$1700(this.this$0).shutdown();
        LayerReport.LayerSE.access$800(LayerReport.LayerThread.access$1800(LayerReport.access$1700(this.this$0))).release();
        this.this$0.release();
      }
      this.released = true;
    }
  }

  private class LayerThread extends Thread
  {
    private boolean forceShutDown;
    private LayerReport.LayerSE layerSE;
    private final LayerReport this$0;

    private LayerThread()
    {
      this.this$0 = paramLayerReport;
      this.forceShutDown = false;
    }

    public void run()
    {
      this.layerSE = new LayerReport.LayerSE(this.this$0, LayerReport.access$100(this.this$0), LayerReport.access$200(this.this$0), null);
      SynchronizedSEList.put(Thread.currentThread(), this.layerSE);
      try
      {
        this.layerSE.dynamic_ex();
      }
      finally
      {
        release();
      }
    }

    public void shutdown()
    {
      if (LayerReport.access$400(this.this$0))
      {
        synchronized (LayerReport.access$500(this.this$0))
        {
          this.forceShutDown = true;
          LayerReport.access$600(this.this$0);
        }
        if (LayerReport.access$400(this.this$0))
          try
          {
            Thread.sleep(100L);
          }
          catch (InterruptedException localInterruptedException)
          {
            FRContext.getLogger().log(Level.WARNING, localInterruptedException.getMessage(), localInterruptedException);
          }
      }
    }

    public void release()
    {
      this.layerSE.releaseTableData(LayerReport.access$700(this.this$0));
      this.layerSE.calculator.release();
      LayerReport.LayerSE.access$800(this.layerSE).release();
      SynchronizedSEList.removeSheetExecuter(Thread.currentThread());
      LayerReport.access$402(this.this$0, false);
      synchronized (LayerReport.access$900(this.this$0))
      {
        if (LayerReport.access$1000(this.this$0))
        {
          FRContext.getLogger().info(Inter.getLocText("Finally") + ", " + Inter.getLocText("Layer-Wake_Up_Thread_For_Page_Retriever"));
          LayerReport.access$900(this.this$0).notifyAll();
          LayerReport.access$1002(this.this$0, false);
        }
      }
    }

    LayerThread(, LayerReport.1 param1)
    {
      this(paramLayerReport);
    }

    static LayerReport.LayerSE access$1800(LayerThread paramLayerThread)
    {
      return paramLayerThread.layerSE;
    }

    static boolean access$2100(LayerThread paramLayerThread)
    {
      return paramLayerThread.forceShutDown;
    }
  }
}